<% url_options = { "action" => "filter" }.merge(params)
  url_options.merge!(controller.filter_url_settings) if controller.respond_to?(:filter_url_settings)
%>
<%= form_tag(url_options, :method => :get, :id => "filter") do %>
  <%= hidden_field_tag 'source_url', params['source_url'] || request.url %>
  <%= link_to I18n.t(:clear_all), '#', :class => 'filter_clear_all' %>
  <% filter_params.each do |filter| %>
    <% next unless filter.display? %>
    <% if lookup_context.find_all("spree/filters/_#{filter.display_param}").any? %>
      <%= render :partial => "spree/filters/#{filter.display_param}", :locals => { :filter => filter }%>
    <% else %>
    <fieldset class="filter" data-field="<%= filter.display_param %>">
      <legend class="sub-header"><%= filter.display_name %></legend>
      <% filter.html_values.each_with_index do |hv, index| %>
      <p class="filter_field">
        <% selected = (!(@searcher and @searcher.query).nil? and @searcher.query.has_filter?(filter, hv[:value])) %>
        <% checkbox_id = "#{filter.display_param}_#{index}" %>
        <label class="filter_field" for="<%= checkbox_id %>">
          <%= check_box_tag "s[#{filter.display_param}][]", hv[:value], selected, { :id => checkbox_id } %>
        </label>
        <label class="filter_value nowrap"><%= hv[:display] %></label>
      </p>
      <% end %>
    </fieldset>
    <% end %>
  <% end %>
  <%= submit_tag I18n.t(:search), :class => 'filter_submit' %>
<% end %>
